<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>NDK Programmer&#39;s Guide: Android System Image Issues</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">NDK Programmer&#39;s Guide
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;"
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('md_4__additional__info__s_y_s_t_e_m-_i_s_s_u_e_s.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Android System Image Issues </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This document contains a list of known issues in existing Android system images that NDK developers should be aware of.</p>
<h2>Android 1.5 System Issues</h2>
<p>The following issues correspond to the official Android 1.5 system images:</p>
<h2>C++ Runtime Support</h2>
<p>The Android C++ system runtime only provides very little support for C++ features (i.e. RTTI, exceptions and Standard Library). However, the NDK provides more advanced runtimes that can be linked into your application, if you need them.</p>
<p>See docs/CPLUSPLUS-SUPPORT.html for more details.</p>
<h2>C Library limitations</h2>
<p>The C library doesn't try to implement every feature under the sun. Most notably, pthread cancellation is not supported. A detailed overview of the C library and its design is available in docs/system/libc/OVERVIEW.html</p>
<h2>No SysV IPCs in C library</h2>
<p>Unix System V Inter-Process Communication APIs (e.g. semget()) are intentionally not available from the C library, to avoid denial-of-service issues. See docs/system/libc/SYSV-IPC.html for details.</p>
<h2>C Library bug: getservbyname() returns port number in incorrect order:</h2>
<p>The Android 1.5 C library function getservbyname() returns the port number corresponding to a given network service in incorrect order. The function stores its result in a 'struct servent' structure, and the port number in its 's_port' field.</p>
<p>The standard mandates that this value is stored in network order (and thus should be converted to host order through ntohs()). However, the 1.5 implementation is buggy and returns the number.</p>
<p>This bug is fixed in later releases of the platform, and applications should not depend on the wrong behaviour in the future. Avoid using this function if possible; if this is not possible, try to use a small wrapper like the following one: </p>
<pre class="fragment">    static struct servent*
    my_getservbyname(const char*  name, const char*  proto)
    {
        static int       has_bug = -1;
        struct servent*  ret;

        if (has_bug &amp;lt; 0) {
            ret = getservbyname("http",NULL);
            has_bug = (ret == NULL || ret-&amp;gt;s_port == 80);
        }

        ret = getservbyname(name, proto);
        if (has_bug)
            ret-&amp;gt;s_port = htons(ret-&amp;gt;s_port);
    }
</pre><p>(the returned struct servent is thread-local and can be modified by the caller. It will be over-written on the next call to the function though).</p>
<h2>Dynamic Linker limitations</h2>
<p>The Android dynamic linker in 1.5 has many important limitations:</p>
<ul>
<li>No support for LD_LIBRARY_PATH, LD_PRELOAD, RTLD_LOCAL and many other options.</li>
<li>Static C++ constructors in executables are called twice due to a bug in the C library initialization sequence. However, static C++ constructors in shared libraries are only called once.</li>
<li>Static destructors are never called at the moment, either at program exit, or when dlclose() is called.</li>
<li>dlerror() reporting is very limited and only provides a few generic error messages that make it difficult to know why a dynamic load/link operation failed. Most of the time, the culprit is a missing symbol.</li>
<li>A bug prevents one application shared library from depending on another one. For example, if you build both libfoo.so and libbar.so for your application, and list libfoo.so as a dependency for libbar.so in bar/Android.mk (with LOCAL_SHARED_LIBRARIES := foo), then loading libbar.so will always fail, even if you have already loaded libfoo.so in your process. </li>
</ul>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Wed Jun 25 2014 00:51:19 for NDK Programmer&#39;s Guide by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.5 </li>
  </ul>
</div>
</body>
</html>
